/*
============================================================================
 Name        : LastFmUI.h
 Author      : 
 Version     :
 Copyright   : Your copyright notice
 Description : CLastFmUI declaration
============================================================================
*/

#ifndef __LASTFMUI_H__
#define __LASTFMUI_H__

// INCLUDES
#include <e32std.h>
#include <e32base.h>

#include "MPluginContainer.h"
#include "ImageHandler.h"			//MImageHandlerObserver

class CWindowGc;
class CFbsBitmap;
class CTicker;

// CLASS DECLARATION
class CLastFmUI : public CBase, public MImageHandlerObserver
{
public: // Constructors and destructor
	~CLastFmUI();
	static CLastFmUI* NewL();
	static CLastFmUI* NewLC();

private:
	CLastFmUI();
	void ConstructL();

private: //from MImageHandlerObserver
	void ImageIsReady(TInt aError);


public:
	enum TLastFmTickerIcon
	{
		EPlay,
		EStop,
		EBuffering,
		EError,
		ENull
	};

public: //new functions
	void Draw(CWindowGc& aGc, const TRect& aRect) const;
	
	void SetTickerIcon(TLastFmTickerIcon aIcon);
	void SetTickerText(const TDesC& aText);
	void SetTickerTextFormat(TRefByValue<const TDesC16> aFmt, ...);

	void SetContainer(MPluginContainer* aContainer);
	void SetTitle(const TDesC& aTitle);
	void SetImageUrl(const TDesC& aImageUrl, TCallBack& aOnFinishCallback);

	void SetIsBuffering(TBool aIsBuffering, TInt aPercent);

	void Activate();
	void Deactivate();

	//Colors
	TRgb BackBorderColor() const { return TRgb(0x0e006a); }
	TRgb BackShadowColor() const { return TRgb(0x0b079f); }
	TRgb BackColor() const { return TRgb(0xe5e5e5); }
	TRgb InsideBorderColor() const { return TRgb(0x26057d); }
	TRgb InsideColor() const { return TRgb(0x5544d1); }
	TRgb ForeColor() const { return InsideBorderColor(); }


private: //data
	//Reference to container
	MPluginContainer* iContainer;

	//Bitmaps
	RPointerArray<CFbsBitmap> iBitmaps;

	//Ticker
	CTicker* iTitle;

	//Check if is buffering
	TBool iIsBuffering;
	TInt iPercent;

	//Metadata
	TBuf<500> iMetadata;

	//Dimensions
	TInt iFontHeight;
	TInt iTextWidth;
	TSize iImageMaxSize;

	//Cover
	CFbsBitmap* iImage;
	CImageHandler* iImageHandler;
	TSize iImageSize;
	enum EImageResult
	{
		EImagePending,
		EImageReady,
		EImageFailed
	} iImageIsReady;

	//Callback on finishing
	TCallBack* iOnFinishCallback;
};

#endif // __LASTFMUI_H__
